import { Behaviour } from "./engine/Behaviour";
import { Serialized } from "./engine/Serialized";

var music = new Audio();

export class Sound extends Behaviour {
    @Serialized('textInput')
    source: string;
    onPlay: boolean = true;
    constructor() {
        super();

    }

    onStart() {

        music.src = this.source
        if (this.onPlay) {
            music.play();
        }
    }

    onUpdate() {
        if (!this.onPlay) {
            music.pause();
        }
        else {
            music.play();
        }
    }

}
